#ifndef HANDLER_H
#define HANDLER_H
#include "../Common/common.h"
#include "gatecommon.h"


class ThirtyMSHandler : public ACE_Event_Handler
{
public:
	 virtual int handle_timeout (const ACE_Time_Value &,const void *arg);
};

class AcceptorHandler : public ACE_Event_Handler
{
public:
	int open(const ACE_INET_Addr & addr);

	virtual ACE_HANDLE get_handle (void) const;

	virtual int handle_input(ACE_HANDLE fd /* = ACE_INVALID_HANDLE */);
	virtual int handle_close(ACE_HANDLE handle, ACE_Reactor_Mask close_mask);
	
private:
	ACE_SOCK_Acceptor m_acceptor;
};


class ClientHandler : public ACE_Event_Handler
{
public:
	ClientHandler();
	~ClientHandler();
	int open();
	virtual ACE_HANDLE get_handle (void) const;
	ACE_SOCK_Stream& peer() { return m_stream; }
	int send(const char* buf, unsigned int len);
	virtual int handle_input(ACE_HANDLE fd /* = ACE_INVALID_HANDLE */);
	virtual int handle_output(ACE_HANDLE fd /* = ACE_INVALID_HANDLE */);
	virtual int handle_close(ACE_HANDLE handle, ACE_Reactor_Mask close_mask);

private:
	ACE_SOCK_Stream	m_stream;

	ACE_Message_Block m_send_buf;
	ACE_Message_Block m_recv_buf;
	unsigned short	  m_mask;
	unsigned int	  m_pos;
	static unsigned int	 s_pos;
};

#endif